package com.yiqi.liebang.feature.mine.view.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.yiqi.liebang.R;
import com.yiqi.liebang.entity.bo.RewardBo;
import com.yiqi.liebang.entity.bo.RewardContentBo;

import java.util.List;

public class RewardAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {
        public static final int TYPE_LEVEL_TITLE = 0;
        public static final int TYPE_LEVEL_CONTENT = 1;

        public RewardAdapter(List<MultiItemEntity> data) {
            super(data);
            addItemType(TYPE_LEVEL_TITLE, R.layout.item_reward_title);
            addItemType(TYPE_LEVEL_CONTENT, R.layout.item_reward);
        }

        @Override
        protected void convert(BaseViewHolder holder, MultiItemEntity item) {
            switch (holder.getItemViewType()) {
                case TYPE_LEVEL_TITLE:

                    final RewardBo lv0 = (RewardBo) item;
                    holder.setText(R.id.tv_reward_title, lv0.getTitle());
                    holder.itemView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            int pos = holder.getAdapterPosition();
                            if (lv0.isExpanded()) {
                                collapse(pos);
                            } else {
                                expand(pos);
                            }
                        }
                    });
                    break;

                case TYPE_LEVEL_CONTENT:
                    final RewardContentBo person = (RewardContentBo) item;
                    holder.setText(R.id.tv_reward, person.getTitle());
                    break;
            }
        }


    }